//
//  GluAsesmentItem.m
//  CareRingApp
//
//  Created  on 2025/2/28.
//
    

#import "GluAsesmentItem.h"
#import <Masonry/Masonry.h>
#import <QMUIKit/QMUIKit.h>
#import "ConfigModel.h"
@implementation GluAsesmentItem
{
    UIImageView *_iconView;
    QMUIButton *_titlBtn;
    UILabel *_btnLbl;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self layoutBase];
        
    }
    return self;
}

-(void)layoutBase
{
    _iconView = [UIImageView new];
    _iconView.contentMode = UIViewContentModeScaleAspectFit;
    
    _titlBtn = [[QMUIButton alloc]init];
    [_titlBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    _titlBtn.userInteractionEnabled = NO;
    _titlBtn.contentEdgeInsets = UIEdgeInsetsMake(3, 10, 3, 10);
    
    _btnLbl = [UILabel new];
    _btnLbl.textColor = UIColor.lightGrayColor;
    _btnLbl.numberOfLines = 0;
    
    [self addSubview:_iconView];
    [self addSubview:_titlBtn];
    [self addSubview:_btnLbl];

    [_iconView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.leading.top.equalTo(self);
        
    }];
    
    [_titlBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_iconView);
        make.leading.equalTo(_iconView.mas_trailing).offset(10);
        make.height.equalTo(_iconView.mas_height);
        make.width.greaterThanOrEqualTo(@140);
    }];
    
    [_btnLbl mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(_iconView);
        make.top.equalTo(_iconView.mas_bottom).offset(10);
        make.bottom.equalTo(self.mas_bottom);
        make.trailing.equalTo(self.mas_trailing);
    }];
    
}

-(void)setImage:(UIImage *)iconImage Title:(NSString *)title TitleBgColor:(UIColor *)color BottomString:(NSString *)btmString
{
    
    _iconView.image = iconImage;
    [_titlBtn setTitle:title forState:UIControlStateNormal];
    _titlBtn.backgroundColor = color;
    _btnLbl.text = btmString;
    
    [self layoutIfNeeded];
    _titlBtn.cornerRadius = _titlBtn.bounds.size.height/2;
    
}

-(void)setResultImage:(UIImage *)iconImage Title:(NSString *)title TitleColor:(UIColor *)color BottomString:(NSString *)btmString
{
    
    _iconView.image = iconImage;
    [_titlBtn setTitle:title forState:UIControlStateNormal];
    [_titlBtn setTitleColor:color forState:UIControlStateNormal];
    _titlBtn.contentEdgeInsets = UIEdgeInsetsZero;
    
    _btnLbl.text = btmString;
    [_titlBtn.titleLabel setFont:[UIFont fontWithName:FONT_ARIAL_BOLD size:17]];
    [_titlBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_iconView);
        make.leading.equalTo(_iconView.mas_trailing).offset(5);
        make.height.equalTo(_iconView.mas_height);
    }];
    
    
}


@end
